<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>马思特奥赛培训学校网络管理系统</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>

    <link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/ready.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/demo.css}">
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">

</head>
<body>
<!--<span th:text="session.f"></span>-->
<div class="wrapper">
    <!--    引入公共页面 public-student-index.html 的模块-->
    <div th:replace="student/public-student-index :: header"></div>
    <div th:replace="student/public-student-index :: left"></div>


    <div class="main-panel">
        <div class="content">
            <div class="row">
                <div class="col-md-2"></div>
                <div class="col-md-8">
                    <div class="card" style="width:1000px;height:650px;">
                        <div class="card-header">
                            <h5 class="card-title">课程表</h5>
                        </div>
                        <div class="card-body">
                            <div class="course-position">
                                <table class="course-table" style="font-size: 18px">
                                    <tr>
                                        <th>节次/周次</th>
                                        <th>&emsp;&emsp;星期一</th>
                                        <th>&emsp;&emsp;星期二</th>
                                        <th>&emsp;&emsp;星期三</th>
                                        <th>&emsp;&emsp;星期四</th>
                                        <th>&emsp;&emsp;星期五</th>
                                        <th>&emsp;&emsp;星期六</th>
                                        <th>&emsp;&emsp;星期日</th>
                                    </tr>

                                    <tr>
                                        <td id="T1_0">第一节</td>
                                        <td id="T1_1"></td>
                                        <td id="T1_2"></td>
                                        <td id="T1_3"></td>
                                        <td id="T1_4"></td>
                                        <td id="T1_5"></td>
                                        <td id="T1_6"></td>
                                        <td id="T1_7"></td>
                                    </tr>

                                    <tr>
                                        <td id="T2_0">第二节</td>
                                        <td id="T2_1"></td>
                                        <td id="T2_2"></td>
                                        <td id="T2_3"></td>
                                        <td id="T2_4"></td>
                                        <td id="T2_5"></td>
                                        <td id="T2_6"></td>
                                        <td id="T2_7"></td>
                                    </tr>

                                    <tr>
                                        <td id="T3_0">第三节</td>
                                        <td id="T3_1"></td>
                                        <td id="T3_2"></td>
                                        <td id="T3_3"></td>
                                        <td id="T3_4"></td>
                                        <td id="T3_5"></td>
                                        <td id="T3_6"></td>
                                        <td id="T3_7"></td>
                                    </tr>

                                    <tr>
                                        <td id="T4_0">第四节</td>
                                        <td id="T4_1"></td>
                                        <td id="T4_2"></td>
                                        <td id="T4_3"></td>
                                        <td id="T4_4"></td>
                                        <td id="T4_5"></td>
                                        <td id="T4_6"></td>
                                        <td id="T4_7"></td>
                                    </tr>

                                    <tr>
                                        <td id="T5_0">第五节</td>
                                        <td id="T5_1"></td>
                                        <td id="T5_2"></td>
                                        <td id="T5_3"></td>
                                        <td id="T5_4"></td>
                                        <td id="T5_5"></td>
                                        <td id="T5_6"></td>
                                        <td id="T5_7"></td>
                                    </tr>

                                    <tr>
                                        <td id="T6_0">第六节</td>
                                        <td id="T6_1"></td>
                                        <td id="T6_2"></td>
                                        <td id="T6_3"></td>
                                        <td id="T6_4"></td>
                                        <td id="T6_5"></td>
                                        <td id="T6_6"></td>
                                        <td id="T6_7"></td>
                                    </tr>

                                </table>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-2"></div>
            </div>
        </div>
    </div>
</div>


</body>
<script type="text/javascript">
    function ajax(url, send, postback, f, moth) {
        if (!url) return;
        moth = "GET";
        var ajx = new XMLHttpRequest();
        ajx.open(moth, url, !f);
        ajx.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        if (postback) ajx.onreadystatechange = function () {
            if (ajx.readyState == 4 && ajx.status == 200) postback(ajx.responseText)
        };
        ajx.send(send)
    }

    function creatCourseTab() {
        const stusno = 7650;
        ajax("getCourseTable", "ssid=" + stusno, postback);

        function postback(x) {
            if (x == "no")
                return;
            else {
                var list = eval("(" + x + ")");
                for (var i = 0; i < list.length; i++) {
                    //解析json数据
                    var jieci = list[i].session;
                    var week = list[i].week;
                    var cno = list[i].id;
                    var cname = list[i].courseName;
                    var croom = list[i].courseRoom;
                    var tname = list[i].teacherName;
                    switch (jieci) {
                        case "第一节":
                            jieci = 1;
                            break;
                        case "第二节":
                            jieci = 2;
                            break;
                        case "第三节":
                            jieci = 3;
                            break;
                        case "第四节":
                            jieci = 4;
                            break;
                        case "第五节":
                            jieci = 5;
                            break;
                        case "第六节":
                            jieci = 6;
                            break;
                    }
                    switch (week) {
                        case "星期一":
                            week = 1;
                            break;
                        case "星期二":
                            week = 2;
                            break;
                        case "星期三":
                            week = 3;
                            break;
                        case "星期四":
                            week = 4;
                            break;
                        case "星期五":
                            week = 5;
                            break;
                        case "星期六":
                            week = 6;
                            break;
                        case "星期日":
                            week = 7;
                            break;
                    }
                    //确定单元格
                    var danyuange = document.getElementById("T" + jieci + "_" + week);
                    //写入数据
                    var content = cname + "(" + cno + ")" + "(" + tname + ")" + "<br>" + "(" + croom + ")";
                    danyuange.innerHTML = content;
                    danyuange.style.backgroundColor = "rgb(148, 174, 243)";
                }
            }
        }
    }

    creatCourseTab();
</script>
<script type="text/javascript" th:src="@{/webjars/jquery/1.9.1/jquery.js}"></script>
<script type="text/javascript" th:src="@{/webjars/bootstrap/3.3.7/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/asserts/js/ready.min.js}"></script>

</html>